package com.ziyun.pop.web.modules.production.controller;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.ziyun.pop.modules.production.entity.ErpOrderItemEntity;
import com.ziyun.pop.modules.production.service.ErpOrderItemService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * erp订单商品表
 *
 * @author guizhao
 * @email ...
 * @date 2018-08-22 14:44:58
 */
@RestController
@RequestMapping("production/erporderitem")
public class ErpOrderItemController {

    @Autowired
    private ErpOrderItemService erpOrderItemService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("production:erporderitem:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = erpOrderItemService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{eoItemId}")
    @RequiresPermissions("production:erporderitem:info")
    public R info(@PathVariable("eoItemId") Integer eoItemId){
        ErpOrderItemEntity erpOrderItem = erpOrderItemService.getById(eoItemId);

        return R.ok().put("erpOrderItem", erpOrderItem);
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("production:erporderitem:update")
    public R update(@RequestBody ErpOrderItemEntity erpOrderItem){
        ValidatorUtils.validateEntity(erpOrderItem);
        erpOrderItemService.update(erpOrderItem, new UpdateWrapper<>());//全部更新

        return R.ok();
    }

    /**
     * 订单商品查询
     * @param params
     * @return
     */
    @RequestMapping("/erpOrderItemList")
    public R erpOrderItemList(@RequestParam Map<String, Object> params){
        return erpOrderItemService.queryErpOrderItemList(params);
    }

}
